//
//  AXFUserInfoCell.m
//  AXFEightGroup
//
//  Created by hgj on 2016/12/27.
//  Copyright © 2016年 ya. All rights reserved.
//

#import "AXFUserInfoCell.h"

static NSInteger line = 1;

@interface AXFUserInfoCell ()

@property (weak, nonatomic) IBOutlet UIView *topCellView;
@property (weak, nonatomic) IBOutlet UILabel *title_label;
@property (weak, nonatomic) IBOutlet UILabel *send_time_label;
@property (weak, nonatomic) IBOutlet UILabel *content_label;
@property (weak, nonatomic) IBOutlet UIButton *switchButton;

@end

@implementation AXFUserInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
  [self setupUI];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
    }
    return  self;
}

-(void)setupUI {
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [_switchButton addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
}

- (void)clickBtn {
    
    line =  (line == 1) ? 0 : 1;
    
    self.content_label.numberOfLines = line;
 
//    [_switchButton setTitle:(line == 0 ? @"展开全部" : @"收起全部") forState:UIControlStateNormal];

    
//    if (_content_label.numberOfLines == 1) {
//        self.model.lines = 0;
//    }else{
//        self.model.lines = 1;
//    }

    NotificationCenterPost(@"switchButton", self, nil);
//    [UIView animateWithDuration:0.3 animations:^{
//        [self layoutIfNeeded];
//    }];
}

- (void)dealloc {
    NotificationRemoveObserver(self);
}

- (void)setModel:(AXFDataModel *)model {
    _model = model;
    
    self.title_label.text = model.title;
    self.send_time_label.text = model.send_time;
    self.content_label.text = model.content;
    self.content_label.numberOfLines = line;
    
//    if (model.lines == 0) {
//        _switchButton.titleLabel.text = @"收起全部";
//    } else {
//        _switchButton.titleLabel.text = @"展开全部";
//    }
    
//    line =  (line == 1) ? 0 : 1;
//    
//    _switchButton.titleLabel.text = line == 0 ?  @"收起全部" : @"展开全部";
     [_switchButton setTitle:(line == 0 ? @"收起全部":  @"展开全部") forState:UIControlStateNormal];
    
}

@end
